package com.wanpinghui.wphlibrary.model.glide;

import android.content.Context;
import android.os.Environment;

import com.bumptech.glide.Glide;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory;
import com.bumptech.glide.module.GlideModule;
import com.yunshl.yunshllibrary.storage.StorageManager;

import java.io.File;

/**
 * Created by Administrator on 2016/7/4.
 */

public class GlideConfigModule implements GlideModule {

    @Override
    public void applyOptions(Context context, GlideBuilder builder) {
        builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);//和Picasso配置一样
        //设置磁盘缓存目录（和创建的缓存目录相同）
        File storageDirectory = Environment.getExternalStorageDirectory();
        String downloadDirectoryPath=storageDirectory+"/GlideCache";
        //设置缓存的大小为1G
        int cacheSize = 1000*1000*1000;
        builder.setDiskCache(new DiskLruCacheFactory(StorageManager.getTempPath(), cacheSize));
    }

    @Override
    public void registerComponents(Context context, Glide glide) {
    }
}
